package com.jinduplan.planmanager.mvp.presenter

import com.cxz.kotlin.baselibs.ext.ss
import com.cxz.kotlin.baselibs.mvp.BasePresenter
import com.cxz.kotlin.baselibs.utils.GsonHelper
import com.fphoenixcorneae.util.toast.ToastUtil
import com.jinduplan.planmanager.bean.RequestPutProjectBean
import com.jinduplan.planmanager.mvp.contract.ProjectUploadDetailContract
import com.jinduplan.planmanager.mvp.model.ProjectUploadDetailModel

/**
 * @author admin
 * @date 2018/11/20
 * @desc
 */
class ProjectUploadDetailPresenter :
    BasePresenter<ProjectUploadDetailContract.Model, ProjectUploadDetailContract.View>(),
    ProjectUploadDetailContract.Presenter {

    override fun createModel(): ProjectUploadDetailContract.Model? = ProjectUploadDetailModel()

    override fun getProjectUploadDetailList(project_id: Int) {
        mModel?.getProjectUploadDetailList(project_id)?.ss(mModel, mView, true, onSuccess = {
            if (it.code == 200) {
                mView?.setProjectUploadDetailListData(it.data)
            }
        }, onError = {
            ToastUtil.show(it.msg)
        })
    }

    override fun getNewProjectUploadDetailList(project_id: Int) {
        mModel?.getNewProjectUploadDetailList(project_id)?.ss(mModel, mView, true, onSuccess = {
            if (it.code == 200) {
                mView?.setNewProjectUploadDetailListData(it.data)
            }
        }, onError = {
            ToastUtil.show(it.msg)
        })
    }

    override fun getProjectLabour(project_id: Int) {
        mModel?.getProjectLabourList(project_id)?.ss(mModel, mView, true, onSuccess = {
            if (it.code == 200) {
                mView?.setProjectLabour(it.data)
            }
        }, onError = {
            ToastUtil.show(it.msg)
        })
    }

    override fun getProjectWorkmanShip(
        page: Int,
        limit: Int,
        hanging_blue_id: Int,
        project_id: Int,
        building_id: Int,
        workmanship_id: Int,
        facade_id: Int
    ) {
        mModel?.getProjectWorkmanShipList(page,limit,hanging_blue_id,project_id,
            building_id, workmanship_id, facade_id)?.ss(mModel, mView, true, onSuccess = {
            if (it.code == 200) {
                mView?.setProjectWorkmanShip(it.data)
            }
        }, onError = {
            ToastUtil.show(it.msg)
        })
    }

    override fun putProjectUpload(jsonData: RequestPutProjectBean) {
        mModel?.putProjectUpload(jsonData)?.ss(mModel, mView, true, onSuccess = {
            if (it.code == 200) {
                mView?.putProjectUploadSuccess(it.data)
            }else{
                ToastUtil.show(it.msg)
            }
        }, onError = {
            ToastUtil.show(it.msg)
        })
    }


}